<?php
 
class AppModel extends Model {
		
function isUploadedFile($check){
	$val = array_shift($check);
	
	if ((isset($val['error']) && $val['error'] == 0) 
			|| (!empty( $val['tmp_name']) && $val['tmp_name'] != 'none')) {
		return is_uploaded_file($val['tmp_name']);
	}
	return false;
}

function isValidFileType($check, $allowedTypes) {
	$val = array_shift($check);
	
	foreach($allowedTypes as $type) {
		if(strtolower($val['type']) == strtolower($type)) {
			return true;
		}
	}
	return false;
}

function limitCount($check, $limit){
	$existing_count = $this->find('count', array('conditions' => $check, 'recursive' => -1));
	return $existing_count < $limit;
}


} //end model.